home *** CD-ROM | disk | FTP | other *** search
/ Super PC 34 / Super PC 34 (Shareware).iso / spc / UTIL / DJGPP2 / V2 / DJTST200.ZIP / tests / libc / dos / spawn.c < prev   
Encoding:
C/C++ Source or Header  |  1995-04-22  |  999 b   |  44 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <process.h>
  4. #include <go32.h>
  5. #include <sys/farptr.h>
  6. #include <dpmi.h>
  7.  
  8. extern char **environ;
  9.  
  10. void show(const char *m)
  11. {
  12.   __dpmi_regs r;
  13.   r.x.sp = r.x.ss = r.x.flags = 0;
  14.   r.x.ax = 0x5800;
  15.   __dpmi_simulate_real_mode_interrupt(0x21, &r);
  16.   printf("%05lx %s: %02x\n", _go32_info_block.linear_address_of_transfer_buffer, m, r.x.ax & 0xff);
  17. }
  18.  
  19. int
  20. main(int argc, char **argv)
  21. {
  22.   unsigned long i;
  23.   int count=1;
  24.   if (argv[1][0] == '-')
  25.   {
  26.     count = atoi(argv[1]+1);
  27.     argc--;
  28.     argv++;
  29.   }
  30.   show("before");
  31.   _farsetsel(_go32_info_block.selector_for_linear_memory);
  32.   for (i=0; i<_go32_info_block.size_of_transfer_buffer; i++)
  33.     _farnspokeb(_go32_info_block.linear_address_of_transfer_buffer+i,
  34.         0x11);
  35.   for (i=0; i<count; i++)
  36.   {
  37.     int r = spawnlp(P_WAIT, argv[1], argv[1], argv[2], argv[3], argv[4], 0);
  38.     printf("r = %d\n", r);
  39.     perror(argv[1]);
  40.   }
  41.   show("after");
  42.   return 0;
  43. }
  44.